Invariant based programming